// 通用类型定义

// API响应类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
}

// 分页数据类型
export interface PageData<T = any> {
  list: T[]
  total: number
  page: number
  size: number
}

// 用户信息类型
export interface UserInfo {
  id: string
  openid?: string
  nickname: string
  avatar: string
  mobile?: string
  email?: string
  status: number
  createTime: string
  updateTime: string
}

// 帖子基础类型
export interface PostBase {
  id: string
  title: string
  content: string
  images?: string[]
  userId: string
  userNickname: string
  userAvatar: string
  viewCount: number
  likeCount: number
  commentCount: number
  status: number
  isTop: boolean
  createTime: string
  updateTime: string
}

// 表白墙类型
export interface BoardPost extends PostBase {
  type: 'board'
  isAnonymous: boolean
}

// 兼职招聘类型
export interface JobPost extends PostBase {
  type: 'job'
  salary: string
  workTime: string
  contactWay: string
  location: string
  requirements?: string
}

// 失物招领类型
export interface LostPost extends PostBase {
  type: 'lost'
  lostType: 'lost' | 'found' // 丢失或拾到
  location: string
  contactWay: string
  reward?: string
}

// 闲置买卖类型
export interface LeavePost extends PostBase {
  type: 'leave'
  price: number
  originalPrice?: number
  condition: string
  location: string
  contactWay: string
}

// 新闻类型
export interface NewsPost extends PostBase {
  type: 'news'
  category: string
  summary?: string
  isRecommend: boolean
}

// 评论类型
export interface Comment {
  id: string
  postId: string
  userId: string
  userNickname: string
  userAvatar: string
  content: string
  parentId?: string
  replyToUserId?: string
  replyToUserNickname?: string
  likeCount: number
  status: number
  createTime: string
}

// 收藏类型
export interface Favorite {
  id: string
  userId: string
  postId: string
  postType: string
  postTitle: string
  createTime: string
}

// 搜索参数类型
export interface SearchParams {
  keyword?: string
  type?: string
  category?: string
  page?: number
  size?: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
}

// 表单验证规则类型
export interface FormRule {
  required?: boolean
  message?: string
  trigger?: string | string[]
  min?: number
  max?: number
  pattern?: RegExp
  validator?: (rule: any, value: any, callback: any) => void
}